//引入路由组件
// import Home from '@/views/Home'
// import Search from '@/views/Search'
// import Login from '@/views/Login'
// import Register from '@/views/Register'
// import Detail from '@/views/Detail'
// import AddCartSuccess from '@/views/AddCartSuccess'
// import ShopCart from '@/views/ShopCart'
// import Trade from '@/views/Trade'
// import Pay from '@/views/Pay'
// import Paysuccess from '@/views/PaySuccess'
// import Center from '@/views/Center'
// //引入二级路由组件
// import MyOrder from '@/views/Center/myOrder'
// import GroupOrder from '@/views/Center/groupOrder'

// 路由配置信息                     路由懒加载
export default [
  {
    path: '/center',
    component: () => import('@/views/Center'),
    meta: {
      show: true,
    },
    // 二级路由组件
    children: [
      {
        path: 'myorder',
        component: () => import('@/views/Center/myOrder'),
      },
      {
        path: 'groupOrder',
        component: () => import('@/views/Center/groupOrder'),
      },
      {
        path: '/center',
        redirect: '/center/myorder',
      },
    ],
  },
  {
    path: '/paysuccess',
    component: () => import('@/views/PaySuccess'),
    meta: {
      show: true,
    },
  },
  {
    path: '/pay',
    component: () => import('@/views/Pay'),
    meta: {
      show: true,
    },
    //路由独享守卫
    buforeEnter: (to, from, next) => {
      if (from.path == '/trade') {
        next()
      } else {
        next(false)
      }
    },
  },
  {
    path: '/trade',
    component: () => import('@/views/Trade'),
    meta: {
      show: true,
    },
    //路由独享守卫
    buforeEnter: (to, from, next) => {
      if (from.path == '/shopcart') {
        next()
      } else {
        next(false)
      }
    },
  },
  {
    path: '/shopCart',
    component: () => import('@/views/ShopCart'),
    meta: {
      show: true,
    },
  },
  {
    path: '/addcartsuccess',
    name: 'addcartsuccess',
    component: () => import('@/views/AddCartSuccess'),
    meta: {
      show: true,
    },
  },
  {
    path: '/detail/:skuid',
    component: () => import('@/views/Detail'),
    meta: {
      show: true,
    },
  },
  {
    path: '/home',
    component: () => import('@/views/Home'),
    meta: {
      show: true,
    },
  },
  {
    path: '/search/:keyword?',
    component: () => import('@/views/Search'),
    meta: {
      show: true,
    },
    name: 'search',
    props: ($route) => ({ keyword: $route.params.keyword, k: $route.query.k }),
  },
  {
    path: '/login',
    component: () => import('@/views/Login'),
    meta: {
      show: false,
    },
  },
  {
    path: '/register',
    component: () => import('@/views/Register'),
    meta: {
      show: false,
    },
  },
  //重定向
  {
    path: '/',
    redirect: '/home',
  },
]
